package com.hgw.rocketmqtemplatedemo.listener;

import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * Description: 消费者监听器
 *
 * @author LinHuiBa-YanAn
 * @date 2023/2/15 20:18
 */
@Component
@RocketMQMessageListener(
        consumerGroup = "demo-consumer-group",
        topic = "Demo",
        messageModel = MessageModel.CLUSTERING,
        consumeThreadMax = 1                    // 设置最大线程数为1，确保同一个队列只被一个线程消费。
)
public class MqBaseConsumerListener implements RocketMQListener<Object> {

    @Override
    public void onMessage(Object message) {
        System.out.println("消费消息-" + message);
    }

}
